package com.cyf.app.service.impl;

import com.cyf.app.service.AppPushService;
import com.cyf.app.service.JpushMessageService;
import com.cyf.util.ParkingUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * app推送接口实现类
 * Created by cage on 2017/3/28.
 */
@Service
public class AppPushServiceImpl implements AppPushService {

    private static final Logger logger = LoggerFactory.getLogger(AppPushServiceImpl.class);
    private static final String NOTICETYPE_CARIN = "1";     // 入场通知
    private static final String NOTICETYPE_CAROUT = "2";    // 出场通知
    private static final String NOTICETYPE_COUPON = "3";    // 优惠券通知

    @Autowired
    private JpushMessageService jpushMessageService;

    @Override
    public void pushCouponNotification(String mobile) {
        Map<String, String> extras = new HashMap<>();
        extras.put("noticeType", NOTICETYPE_COUPON);
        //String content = "您有新的优惠券！";
        //logger.info("通知app用户有新的优惠券:{}", content);
        //jpushMessageService.sendPushByAlias(mobile, content, extras);
    }

    @Override
    public void pushCarInNotification(String mobile, String plate, String parkingName) {
        Map<String, String> extras = new HashMap<>();
        extras.put("noticeType", NOTICETYPE_CARIN);
        //String content = "车辆" + plate + "进入" + ParkingUtil.getParkingName(parkingName);
        //logger.info("通知app用户:{}", content);
        //jpushMessageService.sendPushByAlias(mobile, content, extras);

    }

    @Override
    public void pushCarOutNotification(String mobile, String plate, String parkingName) {
        Map<String, String> extras = new HashMap<>();
        extras.put("noticeType", NOTICETYPE_CAROUT);
        //String content = "车辆" + plate + "从" + ParkingUtil.getParkingName(parkingName) + "离开";
        //logger.info("通知app用户:{}", content);
        //jpushMessageService.sendPushByAlias(mobile, content, extras);
    }
}
